<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page session="false" %>
<%@ page isELIgnored ="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<script type="text/javascript">
//<![CDATA[
(function(){
	dojo.byId("lbl_schedule_new_affair").innerHTML = Organization._resource.affair ;
	$kdom.appendDojoProp("input_schedule_new_affair","missingMessage",$ksub(KppModule.commonResource.missingMessage,[Organization._resource.organizationCode]));
	dojo.byId("lbl_schedule_new_begindate").innerHTML = Organization._resource.beginDate;
	dojo.byId("lbl_schedule_new_enddate").innerHTML = Organization._resource.endDate;
	dojo.byId("lbl_schedule_new_active").innerHTML = Organization._resource.workFlag;
	dojo.byId("lbl_schedule_new_active_yes").innerHTML = Organization._resource.workFlagYes;
	dojo.byId("lbl_schedule_new_active_no").innerHTML = Organization._resource.workFlagNo;
	$kdom.appendDojoProp("btn_schedule_new_save","label",KppModule.commonResource.save);
	$kdom.appendDojoProp("btn_schedule_new_cancel","label",KppModule.commonResource.cancel);
})();

function dialogShow(dlgId,content) {
	this.dlg=dijit.byId(dlgId);
	if(!this.dlg)this.dlg=new dijit.Dialog({
		id:dlgId,
		title: KppModule.commonResource.hint,
		style: "padding:0px;width:300px;height:100px;background-color:#FFF;"});
		this.dlg.set("content","<div style=\"padding:20px;text-align:center\">"+content+"</div>");
	this.dlg.show();
}

function dateCompare() {
	var startTime = dijit.byId("input_schedule_new_begindate").getValue();
	var endTime = dijit.byId("input_schedule_new_enddate").getValue();
	if(startTime != null && endTime != null ){
		if(Date.parse(startTime)<Date.parse(endTime)){
			dijit.byId("btn_schedule_new_save").setDisabled(false);
		} else {
			dijit.byId("btn_schedule_new_save").setDisabled(true);
			dialogShow("schedule_new_dateWarn",Organization._resource.dateWarn);
		};
	}
}
//]]>
</script>
<span style="display:none">To solve IE7/8 script event tag problem.</span>
<div data-dojo-type="dijit.form.Form" data-dojo-props="action:'../../organization/calendar/newschedule.do?oid=${orgId}',id:'frm_schedule_new'">
	<table width="100%">
		<tr>
			<td><label id="lbl_schedule_new_affair">schedule affair</label></td>
			<td><input id="input_schedule_new_affair" data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props="required:true,trim:true,name:'affair',maxLength:20"></input></td>
		</tr>
		<tr>
			<td><label id="lbl_schedule_new_begindate">schedule begin date</label></td>
			<td><input id="input_schedule_new_begindate" data-dojo-type="dijit/form/DateTextBox" data-dojo-props="required:true,name:'beginDate',onBlur:dateCompare"></input></td>
		</tr>
		<tr>
			<td><label id="lbl_schedule_new_enddate">schedule end date</label></td>
			<td><input id="input_schedule_new_enddate" data-dojo-type="dijit/form/DateTextBox" data-dojo-props="required:true,name:'endDate',onBlur:dateCompare"></input></td>
		</tr>
		<tr>
			<td><label id="lbl_schedule_new_active">work flag</label></td>
			<td>
				<div data-dojo-type="dijit.form.RadioButton" data-dojo-props="name:'workdayFlag',value:'1',checked:true"></div><label id="lbl_schedule_new_active_yes">yes</label>
				<div data-dojo-type="dijit.form.RadioButton" data-dojo-props="name:'workdayFlag',value:'0'"></div><label id="lbl_schedule_new_active_no">no</label>
			</td>
		</tr>
	</table>
</div>
<div class="dialogFooter">
	<div id="btn_schedule_new_save" data-dojo-type="dijit.form.Button" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconSave', showLabel:true" style="width:70px;">
		<script type="dojo/on" data-dojo-event="click" data-dojo-args="evt">
			var options = {
				domain:Organization._resource.schedule,
				refresh:Calendar.calendarShow,
				button:this,
				dialogId:"dialog_org_schedule_new",
				formId:"frm_schedule_new",
				resource:Organization._resource
			};
			KppModule.restProxy(options).postNew();
		</script>
	</div>
	<div id="btn_schedule_new_cancel" data-dojo-type="dijit.form.Button" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconUndo', showLabel:true" style="width:70px;">
		<script type="dojo/on" data-dojo-event="click" data-dojo-args="evt">
				dijit.byId("dialog_org_schedule_new").hide();
		</script>
	</div>
</div>